package com.meiyou.controller;

import com.meiyou.dto.StarDto;
import com.meiyou.dto.StarPageDto;
import com.meiyou.result.PageResult;
import com.meiyou.result.Result;
import com.meiyou.service.StarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/api/star")
public class StarController {
    @Autowired
    private StarService starService;

    /**
     * 点赞、取消点赞文章
     *
     * @param starDto
     * @return
     */
    @PostMapping
    public Result starOrCancel(@RequestBody StarDto starDto) {

        starService.starOrCancel(starDto);

        return Result.success("操作成功！");
    }

    /**
     * 获取用户文章被点赞数
     *
     * @return
     */
    @GetMapping
    public Result<Integer> getStarNum() {

        Integer count = starService.getStarNum();

        return Result.success(count);
    }

}

